<?php

namespace Es\Struct;
/**
 * 索引结构体
 */
class IndexStruct 
{
    private $index;
    private $settings;
    private $mappings;
    
    public function __construct(
        string $index, 
        IndexSettingsStruct $settings,
        IndexMappingsStruct $mappings
    )
    {
        $this->index    = $index;
        $this->settings = $settings;
        $this->mappings = $mappings;
    }

    public function asArray(): array
    {
        return [
            'index' => $this->index,
            'body'  => [
                'settings' => $this->settings->asArray(),
                'mappings' => $this->mappings->asArray(),
            ]
        ];
    }
}
